const btn = this.document.querySelector('#btn')
const BrowserWindow =require('electron').remote.BrowserWindow

window.onload = function(){
   btn.onclick = ()=>{

        newWin = new BrowserWindow({
            width:500,
            height:500,
        })
        newWin.loadFile('yellow.html')
        newWin.on('close',()=>{win=null})

    }
}

const { remote} = require('electron')

var rigthTemplate = [
    {label:'粘贴', accelerator: `ctrl+c`},
    {label:'复制', accelerator: `ctrl+v`}
]

var m = remote.Menu.buildFromTemplate(rigthTemplate)

window.addEventListener('contextmenu',function(e){
    // alert(111);
    //阻止当前窗口默认事件
    e.preventDefault();
    //把菜单模板添加到右键菜单
    m.popup({window:remote.getCurrentWindow()})
})

var mybtn = document.querySelector('#mybtn')

mybtn.onclick = function(e){
    window.open('./popup_page.html')
}

window.addEventListener('message',(msg)=>{
    let mytext = document.querySelector('#myText')
    // mytext.innerHTML = JSON.stringify(msg)
    mytext.innerHTML = JSON.stringify(msg.data)
})